package store.lunangangster.bpmn.model;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 子流程主要用于两种场景：
 * <p>1. 用于逻辑的分层，便于流程的编写
 * <p>2. 用于数据隔离，父流程无法引用到子流程中的数据
 *
 * @author cwk
 * @version 1.0
 */
public class SubProcess extends Activity implements FlowElementsContainer {

  protected Map<String, FlowElement> flowElements = new LinkedHashMap<>();

  // the element to start this Process
  protected FlowElement initialElement;

  @Override
  public void addFlowElement(FlowElement flowElement) {
    flowElements.put(flowElement.id, flowElement);
  }

  @Override
  public Map<String, FlowElement> getFlowElements() {
    return flowElements;
  }

  @Override
  public void setFlowElements(
      Map<String, FlowElement> flowElements) {
    this.flowElements = flowElements;
  }

  @Override
  public FlowElement getInitialElement() {
    return initialElement;
  }

  @Override
  public void setInitialElement(FlowElement initialElement) {
    this.initialElement = initialElement;
  }

  @Override
  public String getModelType() {
    return "SUB_PROCESS";
  }
}
